#============================================
# #知识点
# 一些进程/线程 需要等待另外一些进程/线程运行完毕之后才能运行，类似于发射信号- -样
# from threading import Thread,Event
# import time 
# def light():
#     print("红灯亮")
#     time.sleep(3)
#     print("绿灯亮了")
#     event.set()

# def car(i):
#     print(f"{i}号车正在等红灯!")
#     event.wait()
#     print(f"{i}号车通过了!")

# if __name__ == "__main__":
#     event = Event()
#     x = Thread(target=light) 
#     x.start()

#     for i in range(10):
#        x = Thread(target=car,args=(i,)) 
#        x.start()
#============================================
#线程q(了解)
#第一种
import queue
# q = queue.Queue()
# for i in range(5):
#     q.put(i)
# for i in range(5):
#     print(q.get())
# print("======")
# q.empty()
# q.full()
# q.get_nowait()
# q.get(timeout=3)

#第二种
# q = queue.LifoQueue()   #先进后出
# for i in range(5):
#     q.put(i)
# for i in range(5):
#     print(q.get())
# print("======")

#第三种
q = queue.PriorityQueue()#优先级出入(越小越高)
for i in range(1,6):
    q.put((i,"*"*i))
for i in range(5):
    x,data = q.get()
    print(data)
print("======")
#============================================